@stampede, it compiles, but if you modify the code to "track" the constructors calls
#include <iostream>
class Test{
public:
Test(){
std::cout << "Test()\n";
}
Test(int){
std::cout << "Test(int)\n";
}
};
int main(){
Test t;
Test t1();
Test t2(1);
std::cin.get();
return 0;
}
#include <iostream>
class Test{
public:
Test(){
std::cout << "Test()\n";
}
Test(int){
std::cout << "Test(int)\n";
}
};
int main(){
Test t;
Test t1();
Test t2(1);
std::cin.get();
return 0;
}
To copy to clipboard, switch view to plain text mode
You will see that only one Test() and one Test(int), that is because Test t1(); is "compiled" as a function declaration (a function called t1 that returns a Test and takes no parameter)
//i can't test right now, but as far as i know this is the standard C++ behavior.
Bookmarks